< previous page page_71 next page >

Page 71
    With rsDynaset
        .AddNew
        For intLoop = 0 To UBound(varRecords, 1)
            .Fields(intLoop).Value = varRecords(intLoop, 0)
        Next
        .Update
    End With
    '
End Sub
Although there is not a lot of code in this example, there are a few things worth pointing out. First, you see extensive use of the With..End With construct in Listing 3.14. This construct was introduced in Visual Basic 4.0 and is very useful when working with Visual Basic objects. Using the With..End With construct is faster than naming the same objects several times in code.
Also, notice the use of the GetRows method of the Recordset. This method fills a variant data variable with the contents of one or more records from the Recordset. This is a very efficient way to read several records into memory without using the slower For..Next loops.
When you run the SNAPSHOTS.VBP program, you see three record count reports. The first report occurs right after the data objects are created. The second count report occurs after a record has been removed from the Dynaset object. The last count report occurs after the record has been restored to the Dynaset object. Note that both the Table and the Dynaset objects reflect the changes in the data table, but the Snapshot does not (see Figure 3.8).
0071-01.jpg
Figure 3.8.
Comparing Dynasets,
Snapshots, and Tables.

 
< previous page page_71 next page >

If you like this book, buy it!